
package view;

/**
 *
 * @author Erol Hira
 */
public class SoftMenu extends List{
    
    private byte position;
    public static final byte JUST_OVER_BUTTON = 1;
    public static final byte CENTERED = 2;
    
    private byte softButtonType;
    
    
    public SoftMenu(String[][] data, int y, int width, int height, byte lineHeight) {
        super(data, y, width, height, lineHeight);
    }

    protected void init() {
        super.init();
        z_order = MIN_Z_ORDER;
        visible = false;
    }        
    
    private void setup_JUST_OVER_BUTTON(){
        
        y = container.getHeight() - SoftMenuButton.softButtonHeight - height;
        
        if(SoftMenuButton.LEFT == softButtonType){
            x = 0;
        } else if(SoftMenuButton.RIGHT == softButtonType){
            x = container.getWidth() - getWholeWidth();
        }        
    }
    
    private void setup_CENTERED(){
        //default of List, so do nothing
    }

    public byte getPosition() {
        return position;
    }

    public void setPosition(byte position) {
        this.position = position;
        if(JUST_OVER_BUTTON == position){
            setup_JUST_OVER_BUTTON();
        } else if(CENTERED == position){
            setup_CENTERED();
        }
    }

    public byte getSoftButtonType() {
        return softButtonType;
    }

    public void setSoftButtonType(byte softButtonType) {
        this.softButtonType = softButtonType;
    }
    
    protected void doFire() {
        super.doFire();
        container.undoSoftButtons();
    }

    protected void setHighLevelProperty(int property, String value) {
        
        if(Fields.POSITION == property){
            
            position = Byte.parseByte(value);
            
        } else if(Fields.SOFT_BUTTON_TYPE == property){
            
            softButtonType = Byte.parseByte(value);
            
        }
    }
            
}
